-------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/Wei/Dropbox/Fertility/Results/CFPS_data.log
  log type:  text
 opened on:  21 Jan 2020, 10:34:35

. 
. use "$path1/fulllaunch10/cfps2010adult_report.dta", clear 

. merge m:1 fid  using "$path1/fulllaunch10/cfps2010family_report.dta", keepusing(fincome faminc_
> net indinc_net) nogen

    Result                           # of obs.
    -----------------------------------------
    not matched                           369
        from master                       116  
        from using                        253  

    matched                            33,484  
    -----------------------------------------

. ren indinc_net fincome2_per

. ren faminc_net fincome2

. ren fincome finc

. 
. gen prov = qa102acode
(253 missing values generated)

. replace prov = provcd if prov <=0 
(80 real changes made)

. 
. gen sex = gender
(253 missing values generated)

. gen year = 2010 

. gen year_birth = qa1y_best if qa1y_best > 0 
(254 missing values generated)

. gen smoke = qq2 == 1 

. gen drink = qq3 == 1 

. ren qk801 network

. ren qk802 happiness 

. ren qm403 life_sat 

. 
. gen age = year - year_birth 
(254 missing values generated)

. gen sib = qb1
(253 missing values generated)

. 
. save "$path2/cfps_2010_temp",replace 
(note: file /Users/Wei/Dropbox/Fertility/Workingdata/cfps_2010_temp.dta not found)
file /Users/Wei/Dropbox/Fertility/Workingdata/cfps_2010_temp.dta saved

. /*
> clear 
> cd "$path1/fulllaunch12"
> unicode translate cfps2012adultcombined_072014.dta, invalid
> unicode translate cfps2012famecon_072014.dta, invalid
> use "$path1/fulllaunch12/cfps2012famecon_072014.dta", clear
> */
. use "$path1/fulllaunch12/cfps2012adultcombined_072014.dta", clear 

. merge m:1 fid12  using "$path1/fulllaunch12/cfps2012famecon_072014.dta", keepusing(fincome1 pce
>  fincome2 fincome2_per_adj)  nogen
(label releaseversion already defined)
(label typecomm already defined)
(label urbancomm already defined)
(label urban12 already defined)
(label subsample already defined)
(label subpopulation already defined)
(label qz103 already defined)
(label qz102_s_4 already defined)
(label qz102_s_3 already defined)
(label qz102_s_2 already defined)
(label qz102_s_1 already defined)
(label qz101_s_2 already defined)
(label qz101_s_1 already defined)
(label cyear already defined)
(label iwmode already defined)
(label cid already defined)
(label countyid already defined)
(label provcd already defined)
(label fid10 already defined)
(label fid12 already defined)

    Result                           # of obs.
    -----------------------------------------
    not matched                           203
        from master                       107  
        from using                         96  

    matched                            35,620  
    -----------------------------------------

. ren fincome2_per_adj fincome2_per

. ren fincome1 finc

. gen prov = qa401ccode
(3,661 missing values generated)

. 
. 
. gen sex = cfps2012_gender_best
(96 missing values generated)

. gen year = 2012 

. gen year_birth = cfps2012_birthy_best if cfps2012_birthy_best > 0 
(97 missing values generated)

. gen smoke = qq201 == 1 

. gen drink = qq301 == 1 

. ren qn12012 life_sat

. ren qn12013 family_sat

. 
. gen age = year - year_birth 
(97 missing values generated)

. save "$path2/cfps_2012_temp",replace 
(note: file /Users/Wei/Dropbox/Fertility/Workingdata/cfps_2012_temp.dta not found)
file /Users/Wei/Dropbox/Fertility/Workingdata/cfps_2012_temp.dta saved

. /*
> clear
> cd "$path1/fulllaunch14"
> unicode translate cfps2014_adult_20160601.dta, invalid
> unicode translate cfps2014famecon_20160601.dta, invalid
> */
. use "$path1/fulllaunch14/cfps2014famecon_20160601.dta", clear

. use "$path1/fulllaunch14/cfps2014_adult_20160601.dta", clear 

. merge m:1  fid14  using "$path1/fulllaunch14/cfps2014famecon_20160601.dta", keepusing(finc pce 
> fincome2_per fincome2)  nogen
(label urban14 already defined)
(label subsample10 already defined)
(label subsample14 already defined)
(label subpopulation10 already defined)
(label cmonth already defined)
(label cyear already defined)
(label tape already defined)
(label pid_a_17 already defined)
(label pid_a_16 already defined)
(label pid_a_15 already defined)
(label pid_a_14 already defined)
(label pid_a_13 already defined)
(label pid_a_12 already defined)
(label pid_a_11 already defined)
(label pid_a_10 already defined)
(label pid_a_9 already defined)
(label pid_a_8 already defined)
(label pid_a_7 already defined)
(label pid_a_6 already defined)
(label pid_a_5 already defined)
(label pid_a_4 already defined)
(label pid_a_3 already defined)
(label pid_a_2 already defined)
(label pid_a_1 already defined)
(label cid14 already defined)
(label countyid14 already defined)
(label provcd14 already defined)
(label fid10 already defined)
(label fid12 already defined)

    Result                           # of obs.
    -----------------------------------------
    not matched                           451
        from master                       282  
        from using                        169  

    matched                            36,865  
    -----------------------------------------

. ren provcd14 provcd 

. gen sex = cfps_gender
(169 missing values generated)

.  gen year_birth = cfps_birthy
(169 missing values generated)

. gen smoke = qq201 == 1 

. gen drink = qq301 == 1 

. ren qn12012 life_sat

. ren qn12013 family_sat

. gen year = 2014 

. ren wordtest14 wordtest

. ren mathtest14 mathtest

. save "$path2/cfps_2014_temp",replace 
(note: file /Users/Wei/Dropbox/Fertility/Workingdata/cfps_2014_temp.dta not found)
file /Users/Wei/Dropbox/Fertility/Workingdata/cfps_2014_temp.dta saved

. 
. use "$path1/fulllaunch14/cfps2014famecon_20160601.dta", clear 

. 
. ******* 
. set more off

. use "$path2/cfps_2010_temp", clear 

. append using "$path2/cfps_2012_temp", force 
(note: variable qe506 was str12 in the using data, but will be byte now)
(note: variable pid was long, now double to accommodate using data's values)
(note: variable provcd was byte, now double to accommodate using data's values)
(note: variable countyid was int, now double to accommodate using data's values)
(note: variable cid was int, now double to accommodate using data's values)
(note: variable cyear was int, now double to accommodate using data's values)
(note: variable kr1 was byte, now double to accommodate using data's values)
(note: variable kr2 was byte, now double to accommodate using data's values)
(note: variable kr3 was byte, now double to accommodate using data's values)
(note: variable kr4 was byte, now double to accommodate using data's values)
(note: variable kr403 was byte, now double to accommodate using data's values)
(note: variable kr405 was byte, now double to accommodate using data's values)
(note: variable kr410 was byte, now double to accommodate using data's values)
(note: variable kr420 was int, now double to accommodate using data's values)
(note: variable kr430 was byte, now double to accommodate using data's values)
(note: variable kr431 was byte, now double to accommodate using data's values)
(note: variable kr432 was byte, now double to accommodate using data's values)
(note: variable qe201 was byte, now double to accommodate using data's values)
(note: variable qe212 was byte, now double to accommodate using data's values)
(note: variable qe213 was int, now double to accommodate using data's values)
(note: variable qe311 was byte, now double to accommodate using data's values)
(note: variable qe312 was byte, now double to accommodate using data's values)
(note: variable qe313 was byte, now double to accommodate using data's values)
(note: variable qe401 was byte, now double to accommodate using data's values)
(note: variable qe405y was int, now double to accommodate using data's values)
(note: variable qe405m was byte, now double to accommodate using data's values)
(note: variable qe407 was byte, now double to accommodate using data's values)
(note: variable qe409 was byte, now double to accommodate using data's values)
(note: variable qe503 was byte, now double to accommodate using data's values)
(note: variable qe601 was byte, now double to accommodate using data's values)
(note: variable qe602y was int, now double to accommodate using data's values)
(note: variable qe602m was byte, now double to accommodate using data's values)
(note: variable qe603y was int, now double to accommodate using data's values)
(note: variable qe603m was byte, now double to accommodate using data's values)
(note: variable qe605y was int, now double to accommodate using data's values)
(note: variable qe605m was byte, now double to accommodate using data's values)
(note: variable qe607 was byte, now double to accommodate using data's values)
(note: variable qe608 was int, now double to accommodate using data's values)
(note: variable qf1_a_1 was byte, now double to accommodate using data's values)
(note: variable qf1_a_2 was byte, now double to accommodate using data's values)
(note: variable qf1_a_3 was byte, now double to accommodate using data's values)
(note: variable qf1_a_4 was byte, now double to accommodate using data's values)
(note: variable qf1_a_5 was byte, now double to accommodate using data's values)
(note: variable qf1_a_6 was byte, now double to accommodate using data's values)
(note: variable qf1_a_7 was byte, now double to accommodate using data's values)
(note: variable qf1_a_8 was byte, now double to accommodate using data's values)
(note: variable qf1_a_9 was byte, now double to accommodate using data's values)
(note: variable qf1_a_10 was byte, now double to accommodate using data's values)
(note: variable qf2_s_1 was byte, now double to accommodate using data's values)
(note: variable qf2_s_2 was byte, now double to accommodate using data's values)
(note: variable qf2_s_3 was byte, now double to accommodate using data's values)
(note: variable qf2_s_4 was byte, now double to accommodate using data's values)
(note: variable qf2_s_5 was byte, now double to accommodate using data's values)
(note: variable qf3_s_1 was byte, now double to accommodate using data's values)
(note: variable qf3_s_2 was byte, now double to accommodate using data's values)
(note: variable qf3_s_3 was byte, now double to accommodate using data's values)
(note: variable qf3_s_4 was byte, now double to accommodate using data's values)
(note: variable qf3_s_5 was byte, now double to accommodate using data's values)
(note: variable qg301 was byte, now double to accommodate using data's values)
(note: variable qg303 was byte, now double to accommodate using data's values)
(note: variable qg305 was byte, now double to accommodate using data's values)
(note: variable qg401 was byte, now double to accommodate using data's values)
(note: variable qg402 was byte, now double to accommodate using data's values)
(note: variable qg404 was byte, now double to accommodate using data's values)
(note: variable qg406 was int, now double to accommodate using data's values)
(note: variable qg501 was byte, now double to accommodate using data's values)
(note: variable qg502 was byte, now double to accommodate using data's values)
(note: variable qg503 was byte, now double to accommodate using data's values)
(note: variable qg506 was byte, now double to accommodate using data's values)
(note: variable qg702 was int, now double to accommodate using data's values)
(note: variable qg703 was int, now double to accommodate using data's values)
(note: variable qz201 was byte, now double to accommodate using data's values)
(note: variable qz207 was byte, now double to accommodate using data's values)
(note: variable qz209 was byte, now double to accommodate using data's values)
(note: variable qz211 was byte, now double to accommodate using data's values)
(note: variable qz212 was byte, now double to accommodate using data's values)
(note: variable qa101 was float, now double to accommodate using data's values)
(note: variable qa302 was byte, now double to accommodate using data's values)
(note: variable ks1 was byte, now double to accommodate using data's values)
(note: variable ks2 was byte, now double to accommodate using data's values)
(note: variable ks201 was byte, now double to accommodate using data's values)
(note: variable ks202 was byte, now double to accommodate using data's values)
(note: variable ks4 was byte, now double to accommodate using data's values)
(note: variable ks501 was byte, now double to accommodate using data's values)
(note: variable ks502 was byte, now double to accommodate using data's values)
(note: variable ks503 was byte, now double to accommodate using data's values)
(note: variable ks504 was byte, now double to accommodate using data's values)
(note: variable ks601 was byte, now double to accommodate using data's values)
(note: variable ks602 was byte, now double to accommodate using data's values)
(note: variable ks604 was byte, now double to accommodate using data's values)
(note: variable ks605 was byte, now double to accommodate using data's values)
(note: variable ks701 was byte, now double to accommodate using data's values)
(note: variable ks702 was byte, now double to accommodate using data's values)
(note: variable ks703 was byte, now double to accommodate using data's values)
(note: variable ks704 was byte, now double to accommodate using data's values)
(note: variable ks705 was byte, now double to accommodate using data's values)
(note: variable ks901 was long, now double to accommodate using data's values)
(note: variable ks906 was int, now double to accommodate using data's values)
(note: variable ks904 was int, now double to accommodate using data's values)
(note: variable ks903 was int, now double to accommodate using data's values)
(note: variable qc201 was byte, now double to accommodate using data's values)
(note: variable qc301 was byte, now double to accommodate using data's values)
(note: variable qg602 was byte, now double to accommodate using data's values)
(note: variable qp301 was byte, now double to accommodate using data's values)
(note: variable qp302 was byte, now double to accommodate using data's values)
(note: variable qp401 was byte, now double to accommodate using data's values)
(note: variable qp503_a_1 was byte, now double to accommodate using data's values)
(note: variable qp503_a_2 was byte, now double to accommodate using data's values)
(note: variable qp601 was byte, now double to accommodate using data's values)
(note: variable qp701 was byte, now double to accommodate using data's values)
(note: variable qq201 was byte, now double to accommodate using data's values)
(note: variable qq202 was int, now double to accommodate using data's values)
(note: variable qq203 was float, now double to accommodate using data's values)
(note: variable qq301 was byte, now double to accommodate using data's values)
(note: variable qq302_s_1 was byte, now double to accommodate using data's values)
(note: variable qq302_s_2 was byte, now double to accommodate using data's values)
(note: variable qq302_s_3 was byte, now double to accommodate using data's values)
(note: variable qq303_a_1 was int, now double to accommodate using data's values)
(note: variable qq303_a_2 was byte, now double to accommodate using data's values)
(note: variable qq303_a_3 was int, now double to accommodate using data's values)
(note: variable qq401 was float, now double to accommodate using data's values)
(note: variable life_sat was byte, now double to accommodate using data's values)
(note: variable qz202 was byte, now double to accommodate using data's values)
(note: variable qz203 was byte, now double to accommodate using data's values)
(note: variable qz204 was byte, now double to accommodate using data's values)
(note: variable qz205 was byte, now double to accommodate using data's values)
(note: variable qz206 was byte, now double to accommodate using data's values)
(note: variable qz208 was byte, now double to accommodate using data's values)
(note: variable qz210 was byte, now double to accommodate using data's values)
(note: variable subpopulation was byte, now double to accommodate using data's values)
(note: variable subsample was byte, now double to accommodate using data's values)
(note: variable income was long, now double to accommodate using data's values)
(note: variable releaseversion was float, now double to accommodate using data's values)

. append using "$path2/cfps_2014_temp", force 
(note: variable code_a_f was int, now double to accommodate using data's values)
(note: variable pid_f was long, now double to accommodate using data's values)
(note: variable code_a_m was int, now double to accommodate using data's values)
(note: variable pid_m was long, now double to accommodate using data's values)
(note: variable code_a_s was int, now double to accommodate using data's values)
(note: variable pid_s was long, now double to accommodate using data's values)
(note: variable code_a_c1 was int, now double to accommodate using data's values)
(note: variable pid_c1 was long, now double to accommodate using data's values)
(note: variable code_a_c2 was int, now double to accommodate using data's values)
(note: variable pid_c2 was long, now double to accommodate using data's values)
(note: variable code_a_c3 was int, now double to accommodate using data's values)
(note: variable pid_c3 was long, now double to accommodate using data's values)
(note: variable code_a_c4 was int, now double to accommodate using data's values)
(note: variable pid_c4 was long, now double to accommodate using data's values)
(note: variable code_a_c5 was int, now double to accommodate using data's values)
(note: variable pid_c5 was long, now double to accommodate using data's values)
(note: variable code_a_c6 was int, now double to accommodate using data's values)
(note: variable pid_c6 was long, now double to accommodate using data's values)
(note: variable code_a_c7 was int, now double to accommodate using data's values)
(note: variable pid_c7 was long, now double to accommodate using data's values)
(note: variable code_a_c8 was int, now double to accommodate using data's values)
(note: variable pid_c8 was long, now double to accommodate using data's values)
(note: variable code_a_c9 was int, now double to accommodate using data's values)
(note: variable pid_c9 was long, now double to accommodate using data's values)
(note: variable code_a_c10 was int, now double to accommodate using data's values)
(note: variable pid_c10 was long, now double to accommodate using data's values)
(note: variable qg2 was byte, now double to accommodate using data's values)
(note: variable qg6 was byte, now double to accommodate using data's values)
(note: variable qb301_a_1 was byte, now double to accommodate using data's values)
(note: variable qb302_a_1 was byte, now double to accommodate using data's values)
(note: variable qb301_a_2 was byte, now double to accommodate using data's values)
(note: variable qb302_a_2 was byte, now double to accommodate using data's values)
(note: variable qb301_a_3 was byte, now double to accommodate using data's values)
(note: variable qb302_a_3 was byte, now double to accommodate using data's values)
(note: variable qb301_a_4 was byte, now double to accommodate using data's values)
(note: variable qb302_a_4 was byte, now double to accommodate using data's values)
(note: variable qb301_a_5 was byte, now double to accommodate using data's values)
(note: variable qb302_a_5 was byte, now double to accommodate using data's values)
(note: variable qb301_a_6 was byte, now double to accommodate using data's values)
(note: variable qb302_a_6 was byte, now double to accommodate using data's values)
(note: variable qb301_a_7 was byte, now double to accommodate using data's values)
(note: variable qb302_a_7 was byte, now double to accommodate using data's values)
(note: variable qb301_a_8 was byte, now double to accommodate using data's values)
(note: variable qb302_a_8 was byte, now double to accommodate using data's values)
(note: variable qb301_a_9 was byte, now double to accommodate using data's values)
(note: variable qb302_a_9 was byte, now double to accommodate using data's values)
(note: variable qb301_a_10 was byte, now double to accommodate using data's values)
(note: variable qb302_a_10 was byte, now double to accommodate using data's values)
(note: variable qc401 was byte, now double to accommodate using data's values)
(note: variable ku102 was int, now double to accommodate using data's values)
(note: variable ku2 was byte, now double to accommodate using data's values)
(note: variable ku260 was byte, now double to accommodate using data's values)
(note: variable ku301 was byte, now double to accommodate using data's values)
(note: variable ku302 was byte, now double to accommodate using data's values)
(note: variable ku303 was byte, now double to accommodate using data's values)
(note: variable ku304 was byte, now double to accommodate using data's values)
(note: variable ku305 was byte, now double to accommodate using data's values)
(note: variable ku230 was byte, now double to accommodate using data's values)
(note: variable ku240 was byte, now double to accommodate using data's values)
(note: variable ku601 was byte, now double to accommodate using data's values)
(note: variable ku602 was byte, now double to accommodate using data's values)
(note: variable ku603 was byte, now double to accommodate using data's values)
(note: variable qm501 was byte, now double to accommodate using data's values)
(note: variable qm6 was byte, now double to accommodate using data's values)
(note: variable qn201 was byte, now double to accommodate using data's values)
(note: variable qn202 was byte, now double to accommodate using data's values)
(note: variable qn203 was byte, now double to accommodate using data's values)
(note: variable qq601 was byte, now double to accommodate using data's values)
(note: variable qq602 was byte, now double to accommodate using data's values)
(note: variable qq603 was byte, now double to accommodate using data's values)
(note: variable qq604 was byte, now double to accommodate using data's values)
(note: variable qq605 was byte, now double to accommodate using data's values)
(note: variable qq606 was byte, now double to accommodate using data's values)
(note: variable wordtest was byte, now double to accommodate using data's values)
(note: variable mathtest was byte, now double to accommodate using data's values)
(note: variable qg4 was byte, now double to accommodate using data's values)
(label pce already defined)
(label fincome2 already defined)
(label qz5 already defined)
(label qz212 already defined)
(label qz211 already defined)
(label qz210 already defined)
(label qz209 already defined)
(label qz208 already defined)
(label qz207 already defined)
(label qz206 already defined)
(label qz205 already defined)
(label qz204 already defined)
(label qz203 already defined)
(label qz202 already defined)
(label qz201 already defined)
(label qz103 already defined)
(label qz102_s_3 already defined)
(label qz102_s_2 already defined)
(label qz102_s_1 already defined)
(label qz101_s_2 already defined)
(label qz101_s_1 already defined)
(label qg702 already defined)
(label qg301 already defined)
(label income already defined)
(label kwa2 already defined)
(label kwa1 already defined)
(label kw805 already defined)
(label kw804 already defined)
(label kw803 already defined)
(label kw802 already defined)
(label kw801 already defined)
(label kw705 already defined)
(label kw704 already defined)
(label kw703 already defined)
(label kw702 already defined)
(label kw701 already defined)
(label kw604 already defined)
(label kw603 already defined)
(label kw602 already defined)
(label kw601 already defined)
(label kw504 already defined)
(label kw503 already defined)
(label kw502 already defined)
(label kw501 already defined)
(label kw404 already defined)
(label kw403 already defined)
(label kw402 already defined)
(label kw401 already defined)
(label kw303 already defined)
(label kw302 already defined)
(label kw301 already defined)
(label kw2m already defined)
(label kw2y already defined)
(label kw1 already defined)
(label ks9ckp already defined)
(label ks977 already defined)
(label ks903 already defined)
(label ks904 already defined)
(label ks908 already defined)
(label ks907 already defined)
(label ks905m already defined)
(label ks906 already defined)
(label ks902a already defined)
(label ks901 already defined)
(label ks8 already defined)
(label ks705 already defined)
(label ks704 already defined)
(label ks703 already defined)
(label ks702 already defined)
(label ks701 already defined)
(label ks606m already defined)
(label ks605 already defined)
(label ks604 already defined)
(label ks603m already defined)
(label ks602 already defined)
(label ks601 already defined)
(label ks504 already defined)
(label ks503 already defined)
(label ks502 already defined)
(label ks501 already defined)
(label ks4 already defined)
(label ks3m already defined)
(label ks202 already defined)
(label ks201 already defined)
(label ks2 already defined)
(label ks102b already defined)
(label ks1 already defined)
(label kr406b already defined)
(label kr406 already defined)
(label kr405b already defined)
(label kr405a already defined)
(label kr405 already defined)
(label kr802 already defined)
(label kr801m already defined)
(label kr702 already defined)
(label kr701 already defined)
(label kra605 already defined)
(label kra604 already defined)
(label kra602 already defined)
(label kra601 already defined)
(label kr6m already defined)
(label kr502 already defined)
(label kr501 already defined)
(label kr5m already defined)
(label kr432 already defined)
(label kr431 already defined)
(label kr430 already defined)
(label kr426 already defined)
(label kr425 already defined)
(label kr420a already defined)
(label kr420 already defined)
(label kr413_s_2 already defined)
(label kr413_s_1 already defined)
(label kr410 already defined)
(label kr402me already defined)
(label kr402md already defined)
(label kr402mc already defined)
(label kr402mb already defined)
(label kr402m already defined)
(label kr402ma already defined)
(label kra402 already defined)
(label kra401 already defined)
(label kr4 already defined)
(label kr302 already defined)
(label kr3 already defined)
(label kr201 already defined)
(label kr2 already defined)
(label kra2 already defined)
(label qq501 already defined)
(label qq403b already defined)
(label qq403a already defined)
(label qq402 already defined)
(label qq401 already defined)
(label qq301 already defined)
(label qq205 already defined)
(label qq204 already defined)
(label qq202 already defined)
(label qq2011 already defined)
(label qq201 already defined)
(label qq102_a_7 already defined)
(label qq102_a_6 already defined)
(label qq102_a_5 already defined)
(label qq102_a_4 already defined)
(label qq102_a_3 already defined)
(label qq102_a_2 already defined)
(label qq102_a_1 already defined)
(label qq101_s_7 already defined)
(label qq101_s_6 already defined)
(label qq101_s_5 already defined)
(label qq101_s_4 already defined)
(label qq101_s_3 already defined)
(label qq101_s_2 already defined)
(label qq101_s_1 already defined)
(label qp801_s_9 already defined)
(label qp801_s_8 already defined)
(label qp801_s_7 already defined)
(label qp801_s_6 already defined)
(label qp801_s_5 already defined)
(label qp801_s_4 already defined)
(label qp801_s_3 already defined)
(label qp801_s_2 already defined)
(label qp801_s_1 already defined)
(label qp701 already defined)
(label qp604 already defined)
(label qp603 already defined)
(label qp602 already defined)
(label qp601 already defined)
(label qp501 already defined)
(label qp401 already defined)
(label qp304 already defined)
(label qp303 already defined)
(label qp302 already defined)
(label qp301 already defined)
(label qp2032 already defined)
(label qp2031 already defined)
(label qp202 already defined)
(label qp102 already defined)
(label qp101 already defined)
(label qn6018 already defined)
(label qn6017 already defined)
(label qn6016 already defined)
(label qn6015 already defined)
(label qn6014 already defined)
(label qn6013 already defined)
(label qn6012 already defined)
(label qn6011 already defined)
(label qn1101 already defined)
(label qn402 already defined)
(label qn401_s_4 already defined)
(label qn401_s_3 already defined)
(label qn401_s_2 already defined)
(label qn401_s_1 already defined)
(label qn1017 already defined)
(label qn1016 already defined)
(label qn1015 already defined)
(label qn1014 already defined)
(label qn1013 already defined)
(label qn1012 already defined)
(label qn1011 already defined)
(label qn12014 already defined)
(label qn12013 already defined)
(label qn12012 already defined)
(label qn12011 already defined)
(label orderrand already defined)
(label qn8012 already defined)
(label qn8011 already defined)
(label qn10026 already defined)
(label qn10025 already defined)
(label qn10024 already defined)
(label qn10023 already defined)
(label qn10022 already defined)
(label qn10021 already defined)
(label qn1001 already defined)
(label qc305_a_2 already defined)
(label qc304_a_2 already defined)
(label qc303_a_2 already defined)
(label qc302_a_2 already defined)
(label qc305_a_1 already defined)
(label qc304_a_1 already defined)
(label qc303_a_1 already defined)
(label qc302_a_1 already defined)
(label qc301 already defined)
(label qc201 already defined)
(label qa902 already defined)
(label qa901 already defined)
(label qa9 already defined)
(label qa303m already defined)
(label qa303y already defined)
(label qa603 already defined)
(label qa602ccode already defined)
(label qa602 already defined)
(label qa601 already defined)
(label qa503 already defined)
(label qa502ccode already defined)
(label qa502 already defined)
(label qa501 already defined)
(label qa401ccode already defined)
(label qa401 already defined)
(label cmonth already defined)
(label cyear already defined)
(label qp605_s_5 already defined)
(label qp605_s_4 already defined)
(label qp605_s_3 already defined)
(label qp605_s_2 already defined)
(label qp605_s_1 already defined)
(label qp201 already defined)
(label qi102m already defined)
(label qi101 already defined)
(label qg201 already defined)
(label qg101 already defined)
(label ks9total_m already defined)
(label kr1 already defined)
(label kra1 already defined)
(label wc01 already defined)
(label qa701code already defined)
(label qa302ccode already defined)
(label qa302 already defined)
(label qa301 already defined)
(label cfps_party already defined)
(label cfps_minzu already defined)
(label fid10 already defined)
(label fid12 already defined)

. cap erase "$path2/cfps_2010_temp.dta"

. cap erase "$path2/cfps_2012_temp.dta"

. cap erase "$path2/cfps_2014_temp.dta"

. 
. 
. drop  qb301_a_1- qb312_a_15 code_a_c1-td8_a_c10 qf201_s_1- jobc2lastdate_a_10

. drop egc2012y_a_1- yincomea_b_1 egc2051_min_a_1- yincomea_b_1_new

. 
. egen gender_best = mean(sex), by(pid)
(518 missing values generated)

. replace gender_best =  round(gender_best )
(275 real changes made)

. replace sex = gender_best 
(106 real changes made)

. 
. 
. egen birthy_best = mean(year_birth), by(pid)
(519 missing values generated)

. replace year_birth =  round(birthy_best )
(463 real changes made)

. 
. 
. replace prov = . if prov < 0 
(31,728 real changes made, 31,728 to missing)

. egen prov_best = mean(prov), by(pid)
(20660 missing values generated)

. replace prov = prov_best 
(52,298 real changes made)

. replace prov = provcd if mi(prov)
(20,142 real changes made)

. drop if prov <0 | mi(prov)
(620 observations deleted)

. 
. egen educ_best = mean(educ), by(pid)
(20782 missing values generated)

. replace educ = educ_best
(52,000 real changes made)

. 
. 
. gen women = sex == 0 

. 
. 
. ren year yr_t

. qui:{

. 
. forvalues ag = 1(1)3{
  2. g year = year_birth - `ag' 
  3. merge m:1 prov year using "$path2/fines_use", keepusing(fine) nogen
  4. replace fine = 0 if year < 1979
  5. ren fine fine_f`ag'
  6. drop year
  7. }
(4,198 missing values generated)
(label provcnlbl already defined)

    Result                           # of obs.
    -----------------------------------------
    not matched                        81,584
        from master                    81,255  
        from using                        329  

    matched                            29,314  
    -----------------------------------------
(77,057 real changes made)
(4,527 missing values generated)
(label provcnlbl already defined)

    Result                           # of obs.
    -----------------------------------------
    not matched                        83,427
        from master                    83,070  
        from using                        357  

    matched                            27,828  
    -----------------------------------------
(78,543 real changes made)
(4,884 missing values generated)
(label provcnlbl already defined)

    Result                           # of obs.
    -----------------------------------------
    not matched                        85,298
        from master                    84,913  
        from using                        385  

    matched                            26,342  
    -----------------------------------------
(80,029 real changes made)

. 
. 
. ren yr_t year 

. egen fine_birth = rowmean(fine_age0)
(4965 missing values generated)

. egen fine_1_9 = rowmean(fine_age1-fine_age9)
(3689 missing values generated)

. egen fine_10_19 = rowmean(fine_age10-fine_age19)
(6120 missing values generated)

. egen fine_20_25 = rowmean(fine_age20-fine_age25)
(24318 missing values generated)

. egen fine_0_10 = rowmean(fine_age0-fine_age10)
(3277 missing values generated)

. egen fine_11_20 = rowmean(fine_age11-fine_age20)
(7332 missing values generated)

. egen fine_21_25 = rowmean(fine_age21-fine_age25)
(26128 missing values generated)

. 
. 
. egen fine_0_6 = rowmean(fine_age0-fine_age6)
(3714 missing values generated)

. egen fine_7_12 = rowmean(fine_age7-fine_age12)
(4621 missing values generated)

. egen fine_13_18 = rowmean(fine_age13-fine_age18)
(10896 missing values generated)

. egen fine_19_25 = rowmean(fine_age19-fine_age25)
(22392 missing values generated)

. 
. egen fine_8_15 = rowmean(fine_age8-fine_age15)
(4865 missing values generated)

. 
. egen fine_f2_5 = rowmean(fine_f2 fine_f1 fine_age0 fine_age1-fine_age5)
(3168 missing values generated)

. egen fine_6_10 = rowmean(fine_age6-fine_age10)
(4692 missing values generated)

. egen fine_11_15 = rowmean(fine_age11-fine_age15)
(7868 missing values generated)

. egen fine_16_20 = rowmean(fine_age16-fine_age20)
(16327 missing values generated)

. 
. 
. 
. keep if age >= 25 
(9,923 observations deleted)

. keep if  year_birth >= 1940 & year_birth <= 1980
(29,508 observations deleted)

. gl FINE_VAR = "fine_0_6 fine_7_12 fine_13_18 fine_19_25"

. gl X_VAR = "fine_0_10 fine_11_20 fine_21_25"

. 
. replace life_sat = . if life_sat < 0 | life_sat > 10 
(201 real changes made, 201 to missing)

. gen senior = educ >= 7 if !mi(educ)
(8,128 missing values generated)

. 
. gen local_status = qm402 
(47,626 missing values generated)

. replace local_status = qn8012 if mi(local_status)
(44,072 real changes made)

. 
. 
. gen height = qp1 
(47,626 missing values generated)

. replace height = qp101 if mi(height)
(45,215 real changes made)

. replace height = . if height < 100 | height > 200
(2,185 real changes made, 2,185 to missing)

. 
. gen hlth = qp3 
(47,626 missing values generated)

. replace hlth = qp201 if mi(hlth)
(47,626 real changes made)

. 
. replace happiness = qm2012 if year == 2014
(21,607 real changes made)

. replace happiness = . if happiness < 0 
(125 real changes made, 125 to missing)

. replace happiness = happiness * 2 if year == 2010
(24,509 real changes made)

. 
. cap drop confidence hav_conf

. gen confidence = qn12014
(28,137 missing values generated)

. replace confidence = qm404 if mi(confidence)
(24,583 real changes made)

. gen hav_conf =    confidence ==4 | confidence == 5  if !mi(confidence)
(3,554 missing values generated)

. gen sat_life = life_sat ==4 | life_sat == 5 if !mi(life_sat)
(3,755 missing values generated)

. gen sat_marr =    qm801 ==4 | qm801 == 5  if !mi(qm801) & qm801 >0 
(52,580 missing values generated)

. gen sat_econ_other = qm802 == 4 | qm802 == 5  if !mi(qm802)
(50,602 missing values generated)

. gen sat_duty_other =  qm803 ==  4| qm803 == 5  if !mi(qm803)
(50,602 missing values generated)

. gen high_status =  local_status ==  4| local_status == 5  if !mi(local_status)
(3,554 missing values generated)

. gen bad_gov =  qn1101 ==  4| qn1101 == 5  if !mi(qn1101)
(28,137 missing values generated)

. gen healthy = (hlth ==1 & year == 2010) | (hlth <=3 & year >= 2012) if !mi(hlth)

. gen imp_son_live = qm1003 == 5| qm1003 == 4  if !mi(qm1003)
(50,602 missing values generated)

. gen imp_son_birth = qm1004 == 5| qm1004 == 4  if !mi(qm1003)
(50,602 missing values generated)

. gen agree_women_marr =  qm1102 == 5 | qm1102 == 4    if !mi(qm1102)
(50,602 missing values generated)

. gen agree_women_chid =  qm1103 == 5 | qm1103 == 4    if !mi(qm1103)
(50,602 missing values generated)

. 
. *replace hav_conf = . if confidence <=0 & confidence >10  | year < 2012 
. replace sat_duty_other = . if year < 2012
(0 real changes made)

. gen men = 1-women

. 
. 
. gen lndrowry = ln(qm9) if women == 1
(66,056 missing values generated)

. replace lndrowry = . if women == 0 
(0 real changes made)

. replace lndrowry = ln(qm9) if women == 1
(0 real changes made)

. replace lndrowry =. if lndrowry < 3 & lndrowry >10
(0 real changes made)

. cap gen men = 1-women

. egen fine_8_25 = rowmean(fine_age8-fine_age25)

. egen fine_8_22 = rowmean(fine_age8-fine_age22)

. egen fine_16_22 = rowmean(fine_age16-fine_age22)

. 
. egen fine_6_20 = rowmean(fine_age6-fine_age20)

. egen fine_6_15 = rowmean(fine_age6-fine_age15)

. gen happy = happiness >= 8 if !mi(happiness)
(26,144 missing values generated)

. 
. gen n_sib = qb1 if qb1 >=0 
(47,958 missing values generated)

. replace mathtest = . if mathtest<0 
(29 real changes made, 29 to missing)

. replace wordtest = . if wordtest<0 
(26 real changes made, 26 to missing)

. pca mathtest wordtest

Principal components/correlation                 Number of obs    =     46,161
                                                 Number of comp.  =          2
                                                 Trace            =          2
    Rotation: (unrotated = principal)            Rho              =     1.0000

    --------------------------------------------------------------------------
       Component |   Eigenvalue   Difference         Proportion   Cumulative
    -------------+------------------------------------------------------------
           Comp1 |       1.8025      1.60499             0.9012       0.9012
           Comp2 |      .197504            .             0.0988       1.0000
    --------------------------------------------------------------------------

Principal components (eigenvectors) 

    ------------------------------------------------
        Variable |    Comp1     Comp2 | Unexplained 
    -------------+--------------------+-------------
        mathtest |   0.7071    0.7071 |           0 
        wordtest |   0.7071   -0.7071 |           0 
    ------------------------------------------------

. predict cognition
(score assumed)
(1 components skipped)

Scoring coefficients 
    sum of squares(column-loading) = 1

    ----------------------------------
        Variable |    Comp1     Comp2 
    -------------+--------------------
        mathtest |   0.7071           
        wordtest |   0.7071   -0.7071 
    ----------------------------------

. replace eduy = . if eduy >17
(35 real changes made, 35 to missing)

. ren fincome2 finc_net 

. ren fincome2_per finc_net_per

. 
. gen lnfinc = ln(finc)
(4,948 missing values generated)

. gen lnfinc_per = ln(finc) - ln(finc_net/finc_net_per)
(7,247 missing values generated)

. gen lnfinc_net = ln(finc_net)
(5,442 missing values generated)

. gen lnfinc_net_per = ln(finc_net_per)
(3,709 missing values generated)

. gen lnpce = ln(pce)
(29,722 missing values generated)

. 
. replace lnpce = . if lnpce < 7 | lnpce > 13
(114 real changes made, 114 to missing)

. replace lnfinc_per = . if lnfinc_per < 5 | lnfinc_per > 13
(450 real changes made, 450 to missing)

. replace lnfinc_net_per = . if lnfinc_net_per < 5 | lnfinc_net_per > 13
(700 real changes made, 700 to missing)

. keep *id women men cog* *test senior eduy prov year_birth fine* n_sib year age happ* sat* agree
> * finc* pce lndrowry lnf* lnpce

. replace age = year - year_birth
(24,040 real changes made)

. *compress 
. save "$path2/CFPS_OCP",replace 
file /Users/Wei/Dropbox/Fertility/Workingdata/CFPS_OCP.dta saved

. 
. log close 
      name:  <unnamed>
       log:  /Users/Wei/Dropbox/Fertility/Results/CFPS_data.log
  log type:  text
 closed on:  21 Jan 2020, 10:37:00
-------------------------------------------------------------------------------------------------
